﻿using System;
using System.Web.UI;
using Pyxis.FluentSelenium.SimpleWebApp.Forum.Domain;

namespace Pyxis.FluentSelenium.SimpleWebApp.Forum
{
    public partial class Viewpost : Page
    {
        protected int index
        {
            get { return Convert.ToInt32(Request.QueryString["index"]); }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadPost();
        }

        private void LoadPost()
        {
            newPost.ParentIndex = index;
            viewPostEntry.Post = FakePersistance.Posts[index];
            lblSubject.Text = FakePersistance.Posts[index].Subject;
            rptReplies.DataSource = FakePersistance.Posts[index].Replies;
            rptReplies.DataBind();
        }

        protected void btnReply_Click(object sender, EventArgs e)
        {
            newPost.ClearFields();
            pnlReply.Visible = true;
        }

        protected void newPost_SaveOrCancel(object sender, EventArgs e)
        {
            LoadPost();
            pnlReply.Visible = false;
        }
    }
}